package edu.tjhsst.androidIntranet;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface.OnClickListener;
import android.os.Looper;

public class IntranetManager {
	
	private static String cookies = null;
	//public static String SERVER = "http://iodine.tjhsst.edu/~2012cbrinton/i2/";
	public static String SERVER = "https://iodine.tjhsst.edu/";
	private static String uid = null;
	
	protected static String getCookies() {
		return cookies;
	}
	
	protected static void logout() {
		cookies = null;
	}
	
	public static boolean isLoggedIn() {
		return cookies!=null;
	}
	
	public static void setCookies(String cookies) {
		IntranetManager.cookies=cookies;
	}
	
	public static void setUID(String uid) {
		IntranetManager.uid=uid;
	}
	
	public static String getUID() {
		return uid;
	}
	
	public static void showErrorMessage(Context callingActivity, CharSequence msg) {
		Looper.prepare();
		AlertDialog.Builder alertBuilder = new AlertDialog.Builder(callingActivity);
		alertBuilder.setMessage(msg);
		alertBuilder.setTitle("Error");
		alertBuilder.setNeutralButton("Ok", null);
		alertBuilder.create().show();
		Looper.loop();
	}
	
	public static void showQuestionMessage(Context callingActivity, CharSequence msg, CharSequence pos, OnClickListener posListener, CharSequence neg, OnClickListener negListener) {
		Looper.prepare();
		AlertDialog.Builder alertBuilder = new AlertDialog.Builder(callingActivity);
		alertBuilder.setMessage(msg);
		alertBuilder.setTitle("Error");
		alertBuilder.setPositiveButton(pos, posListener);
		alertBuilder.setNegativeButton(neg, negListener);
		alertBuilder.create().show();
		Looper.loop();
	}

}
